/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-24
 * Time: 16:32
 */


class Animal {
    public String name;
    public int age;

    static {
        System.out.println("Animal static{}");
    }

    {
        System.out.println("Animal {}");
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal 带有两个参数的构造方法");
    }
    public Animal(){
        System.out.println("Animal 不带参数的构造方法");
    }

    public void eat() {
        System.out.println(name + "正在吃饭");
    }
}

class Dog extends Animal{
    static {
        System.out.println("Dog static{}");
    }

    {
        System.out.println("Dog {}");
    }

    public Dog() {
        System.out.println("Dog 不带参数的构造函数");
    }

    public void wangwang() {
        System.out.println(name + "正在叫");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        Student student = new Student();
    }
}


class Student {
    public String name = "wusuowei";
    private int age;
    private static int size;

    public Student() {
        System.out.println("不带参数的构造方法");
    }

    static {
        System.out.println("静态的代码块");
    }

    {
        name = "caocao";
        System.out.println("非静态代码块/实例代码块/构造代码块 -> 一般用来初始化非静态的数据成员");
    }
}

//class Bird extends Animal{
//    public Bird(){
//        super();
//    }
//}



//class Cat extends Animal{
//    int cs;
//    public Cat(String name, int age,int cs) {
//        super(name, age);
//        this.cs = cs;
//    }
//
//    public Cat(String name, int age) {
//        super(name, age);
//    }
//
//    public void miaomiao() {
//        System.out.println(name + "正在喵喵叫");
//    }
//}



//class Base {
//    //Base是基类的意思
//    public int a;
//    public int b;
//    public int c = 199;
//
//    public void methodBase() {
//        System.out.println("Base");
//    }
//}
//
//class Derived extends Base {
//    //派生类
//    public int c = 9;
//
//    public void methodDerived() {
//        System.out.println("Derived");
//    }
//    public void methodBase(int a) {
//        System.out.println("Derived");
//    }
//    public void func() {
//        super.methodBase();
//        methodDerived();
//    }
//
//}
